import 'package:flutter/material.dart';
import 'package:ball_lion/utils/utils.dart';
import 'package:ball_lion/widgets/base/wqs_image.dart';

import 'package:ball_lion/resources/colours.dart';
import 'package:ball_lion/widgets/base/wqs_text.dart';
import 'package:ball_lion/widgets/gif.dart';

class ExpertLogo extends StatelessWidget {
  const ExpertLogo(
      {super.key,
      required this.logo,
      this.inLive = false,
      this.size = 40,
      this.hasAuth,
      this.planCnt,
      this.authIcon,
      this.authSize});

  final String? logo;
  final bool? inLive;
  final bool? hasAuth;
  final double size;
  final int? planCnt;
  final String? authIcon;
  final double? authSize;

  @override
  Widget build(BuildContext context) {
    return Stack(
      alignment: AlignmentDirectional.center,
      clipBehavior: Clip.none,
      children: [
        Container(
          clipBehavior: Clip.antiAlias,
          decoration: BoxDecoration(
              border: Border.all(
                  color: Colours.greyEE,
                  width: 0.5,
                  strokeAlign: BorderSide.strokeAlignOutside),
              shape: BoxShape.circle),
          child: QsImage(
              width: size,
              height: size,
              shimmer: true,
              placeholder: Container(),
              errorWidget: Container(),
              imageUrl: logo ?? ''),
        ),
        if (inLive == true)
          Positioned(
            child: SizedOverflowBox(
              size: Size(size, size),
              child: GifWidget(
                  width: size * 1.35,
                  height: size * 1.35,
                  asset: "expert_live.gif",
                  duration: const Duration(milliseconds: 500)),
            ),
          ),
        if (hasAuth == true)
          Positioned(
            bottom: 0,
            right: 0,
            child: Image.asset(
                Utils.getImgPath(authIcon ?? "expert_invite.png"),
                width: authSize ?? 16,
                height: authSize ?? 16),
          ),
        if (planCnt.hasValue)
          Positioned(
            top: 0,
            right: 0,
            child: Container(
                width: 14,
                height: 14,
                alignment: Alignment.center,
                clipBehavior: Clip.antiAlias,
                decoration: BoxDecoration(
                    gradient: const LinearGradient(
                      colors: [Colours.main, Color(0xFFEF366E)],
                    ),
                    shape: BoxShape.circle,
                    border: Border.all(
                        color: Colors.white,
                        width: 1,
                        strokeAlign: BorderSide.strokeAlignOutside)),
                child: QsText("$planCnt",
                    needCenter: true, fontSize: 10, color: Colours.white)),
          )
      ],
    );
  }
}
